Subject: Re: Reading volume name
From: Nigel Hughes <[email-masked]>
To: [email-masked] (Son Huu Le)
Cc: [email-masked], [email-masked]
Date: Wed, 18 May 1994 11:45:36 +0100

In message <[email-masked]>, 
	[email-masked] (Son Huu Le) writes:
> 
> > Hi guys,
> >  OK I have a bit of a problem, I want to check all disk drives for a file
> > in their root. So I need all the volume names, easy I say I will just get
> > a DosList from dosextens. So I knock up this routine, compiles fine, I get
> > all type 2's (Volumes) and the correct number of them, however when I try
> > and get the BPTR to the BSTR I get negative values, zeros and when I try
> > and look at the BSTR I get garbage, even if I get a valid address! Why?
> 
> ARRRGGGHHHH!!! This almost drove me crazy!! (;

No pun intended, I hope 8)

Thanks man, I was begining to think I was the only one on this list that tries
to do things that are not listed in the manuals!

> The problem was a combination of wrong DosList structure and wrong
> interpretation of BSTR.

Ah ha.
 
> Firstly, the DosList should contain a C union of three different structures
> (ie. DosListUnion should be either dol_Handler, dol_Volume or dol_AssignList,
> not all three!) The .dt_Volume newtype provides a workaround.

OK I am being stupid.
 
> Secondly, a BSTR is a BPTR with the first byte containing string length.
> To convert a BPTR to a normal Amiga pointer you must multiply it by 4.
> ie. APTR = BPTR << 2

Yeah, I did try that and still got crap, must have been doing something wrong, again 8)
Ho hum.
 
> Thirdly, you've got a weird way of accessing newtype structures. (;

Yep, but I types this in from memory when I got here, as I forgot my source 8)
 
> Okay, here is the working version.

You're a champ.

Nigel Hughes...